package com.wjk.kylin.mall.common.core.dto.base;

import com.wjk.kylin.mall.common.core.exception.BaseError;
import lombok.Data;

import java.io.Serializable;

@Data
public class BaseOutDTO implements Serializable {
    private static final long serialVersionUID = 1L;

    private int code = 200;
    private String msg = "成功";
    protected BaseOutDTO() {
    }
    //===================error=====================================
    public static BaseOutDTO error() {
        return error("系统异常");
    }
    public static BaseOutDTO error(String msg) {
        return error(100,msg);
    }
    public static BaseOutDTO error(int code, String msg) {
        BaseOutDTO data = new BaseOutDTO();
        data.setCode(code);
        data.setMsg(msg);
        return data;
    }
    public static BaseOutDTO error(BaseError baseError) {
        BaseOutDTO data = new BaseOutDTO();
        data.setCode(baseError.getCode());
        data.setMsg(baseError.getMsg());
        return data;
    }

    //==============================success==========================
    public static BaseOutDTO success() {
        return success("成功");
    }

    public static BaseOutDTO success(String msg) {
        return success(200,msg);
    }

    public static BaseOutDTO success(int code, String msg) {
        BaseOutDTO data = new BaseOutDTO();
        data.setCode(code);
        data.setMsg(msg);
        return data;
    }

}
